package ae.pcfc.cldos.online.web.controller.base;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.ModelAttribute;

import ae.pcfc.cldos.online.common.delegate.CountryDelegate;
import ae.pcfc.cldos.online.common.delegate.EmirateDelegate;
import ae.pcfc.cldos.online.common.vo.LabelVO;
import ae.pcfc.cldos.online.common.vo.selectors.CountryVO;
import ae.pcfc.cldos.online.common.vo.selectors.EmirateVO;
import ae.pcfc.cldos.online.common.vo.selectors.SystemValuesVO;
import ae.pcfc.cldos.online.web.Constants;

public abstract class BaseNewVisaController extends BasePageController {

	@Autowired
	@Qualifier("countryDelegate")
	private CountryDelegate countryDelegate;
	
	@Autowired
	@Qualifier("emirateDelegate")
	private EmirateDelegate emirateDelegate;
	
	@ModelAttribute(Constants.__COUNTRY_LIST_REQUEST_MODEL_KEY)
	public List<LabelVO> populateCountryList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<CountryVO> countriesVO = countryDelegate.getContriesVOList();
		
		for (CountryVO countryVO : countriesVO) {
			labelVO = countryDelegate.getMapper().map(countryVO, LabelVO.class);
			labelList.add(labelVO);
		}
		return labelList;
	}
	
	@ModelAttribute(Constants.__EMIRATES_LIST_REQUEST_MODEL_KEY)
	public List<LabelVO> populateEmirateList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<EmirateVO> emiratesVO = emirateDelegate.getEmirateVOList();
		
		for (EmirateVO emirateVO : emiratesVO) {
			labelVO = countryDelegate.getMapper().map(emirateVO, LabelVO.class);
			labelList.add(labelVO);
		}
		return labelList;
	}
	
	
	@ModelAttribute(Constants.__EMPLOYEE_TYPE_LIST_REQUEST_MODEL_KEY)
	public List<LabelVO> populateEmployeeTypeList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		List<SystemValuesVO> employeeTypes = systemValuesDelegate.getEmployeeType();
		
		for(SystemValuesVO systemValue :employeeTypes ){
			
			labelVO = systemValuesDelegate.getMapper().map(systemValue, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__OPTION_LIST_REQUEST_MODEL_KEY)
	public List<LabelVO> populateOptionList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> options = systemValuesDelegate.getOption();
		
		for(SystemValuesVO option :options ){
			
			labelVO = systemValuesDelegate.getMapper().map(option, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__ACCOMMODATION_STATUS_LIST_REQUEST_MODEL_KEY)
	public List<LabelVO> populateAccommodationStatusList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> accommodationStatusList = systemValuesDelegate.getAccomodationStatus();
		
		for(SystemValuesVO status :accommodationStatusList ){
			
			labelVO = systemValuesDelegate.getMapper().map(status, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__JOB_CODE_LIST_REQUEST_MODEL_KEY)
	public List<LabelVO> populateJobCodeList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> jobCodes = systemValuesDelegate.getJobCode();
		
		for(SystemValuesVO jobCode :jobCodes ){
			
			labelVO = systemValuesDelegate.getMapper().map(jobCode, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__RP_PERIOD_LIST_REQUEST_MODEL_KEY)
	public List<LabelVO> populatePRPeriodList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> RPPeriods = systemValuesDelegate.getRPPeriod();
		
		for(SystemValuesVO RPPeriod :RPPeriods ){
			
			labelVO = systemValuesDelegate.getMapper().map(RPPeriod, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__PRIORITY_LIST_REQUEST_MODEL_KEY)
	public List<LabelVO> populatePriorityList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> priorities = systemValuesDelegate.getPriority();
		
		for(SystemValuesVO priority :priorities ){
			
			labelVO = systemValuesDelegate.getMapper().map(priority, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__RELIGION_REQUEST_MODEL_KEY)
	public List<LabelVO> populateReligionList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> religions = systemValuesDelegate.getReligion();
		
		for(SystemValuesVO religion :religions ){
			
			labelVO = systemValuesDelegate.getMapper().map(religion, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__GENDER_REQUEST_MODEL_KEY)
	public List<LabelVO> populateGenderList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> genders = systemValuesDelegate.getGender();
		
		for(SystemValuesVO gender :genders ){
			
			labelVO = systemValuesDelegate.getMapper().map(gender, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__MARITAL_STATUS_REQUEST_MODEL_KEY)
	public List<LabelVO> populateMaritalStatusList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> maritalStatuses = systemValuesDelegate.getMaritalStatus();
		
		for(SystemValuesVO maritalStatus :maritalStatuses ){
			
			labelVO = systemValuesDelegate.getMapper().map(maritalStatus, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__MEDICAL_TYPE_REQUEST_MODEL_KEY)
	public List<LabelVO> populateMedicalTypeList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> medicalTypes = systemValuesDelegate.getMedicalType();
		
		for(SystemValuesVO medicalType :medicalTypes ){
			
			labelVO = systemValuesDelegate.getMapper().map(medicalType, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__BANK_GUARANTEE_REQUEST_MODEL_KEY)
	public List<LabelVO> populateBGFlagList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		List<SystemValuesVO> BGFlags = systemValuesDelegate.getBGFlag();
		
		for(SystemValuesVO BGFlag :BGFlags ){
			
			labelVO = systemValuesDelegate.getMapper().map(BGFlag, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__QUALIFICATION_REQUEST_MODEL_KEY)
	public List<LabelVO> populateQualificationList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> qualificationList = systemValuesDelegate.getQualification();
		
		for(SystemValuesVO qualification :qualificationList ){
			
			labelVO = systemValuesDelegate.getMapper().map(qualification, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	
	@ModelAttribute(Constants.__LANGUAGES_REQUEST_MODEL_KEY)
	public List<LabelVO> populateLanguagesList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> languagesList = systemValuesDelegate.getLanguage();
		
		for(SystemValuesVO language :languagesList ){
			
			labelVO = systemValuesDelegate.getMapper().map(language, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}

	@ModelAttribute(Constants.__CURRENT_VISA_TYPE_REQUEST_MODEL_KEY)
	public List<LabelVO> populateCurrentVisaTypeList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> currentVisaTypeList = systemValuesDelegate.getCurrentVisa();
		
		for(SystemValuesVO currentVisaType :currentVisaTypeList ){
			
			labelVO = systemValuesDelegate.getMapper().map(currentVisaType, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
	@ModelAttribute(Constants.__LAST_ENTRY_PORT_REQUEST_MODEL_KEY)
	public List<LabelVO> populateLastEntryPortList(Locale locale){
		List<LabelVO> labelList = new ArrayList<LabelVO>();
		LabelVO labelVO = new LabelVO();
		
		labelList.add(labelVO);
		
		List<SystemValuesVO> portList = systemValuesDelegate.getImmigrationPort();
		
		for(SystemValuesVO currentVisaType :portList ){
			
			labelVO = systemValuesDelegate.getMapper().map(currentVisaType, LabelVO.class);
			labelList.add(labelVO);
		}
		
		return labelList;
	}
}
